;#############################
;命令：
;nasm -f elf64 day3_0array_2double.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Value in arr[0] is 0.123400.
;Value in arr[1] is 1.234500.
;Value in arr[4] is 4.567800.
;#############################
extern printf

section .data
	msg: db `Value in arr[%d] is %f.\n`, 0
	arr: dq 0.1234, 1.2345, 2.3456, 3.4567, 4.5678

section .text
	global main

main:
	push rbp
	mov rbp, rsp

;######################################
	;float数为qword
	;rdx可存放dword
	;qword不可直接放入dword
	;先放入xmm0
	;再movq rdx, xmm0进行转换

	mov rdi, msg
	mov rsi, 0
	movq xmm0, [arr + 8 * 0]
	movq rdx, xmm0
	call printf

	mov rdi, msg
	mov rsi, 1
	movq xmm0, [arr + 8 * 1]
	movq rdx, xmm0
	call printf

	mov rdi, msg
	mov rsi, 4
	movq xmm0, [arr + 8 * 4]
	movq rdx, xmm0
	call printf

;######################################

	mov eax, 0
	leave
	ret
